<template>
<div class="flex-x" style="display: flex;flex-direction: column;height: 100%;">
  <div class="page-content page-prj" style="flex:2">
    <div class="page-prj__left flex-y">
      <LeftTop class="flex-1"  :data="carIndexData"/>
      <LeftCenter class="flex-1" mt-20  :data="carIndexData"/>
    </div>
    <div class="page-prj__center flex-y">
      <CenterTop :data="carIndexData"/>
      <CenterCenter mt-20 class="flex-1" :data="carIndexData"/>
      <div style="display: flex; justify-content: space-between" class="flex-1">
        <CenterBottom mt-20 style="flex: 1; margin-right: 10px" :data="carEchatsData" @childEvent="handleChildEvent"/>
        <!-- <CenterBottom mt-20 style="flex: 1; margin-right: 10px" :data="carIndexData"/> -->
      </div>
    </div>
    <div class="page-prj__right flex-y">
      <RightTop class="flex-1" :data="carIndexData"/>
      <RightCenter class="flex-1" mt-20 :data="carIndexData"/>
    </div>
  </div>
   <Top style="flex:1" :data="carIndexData"/>
   </div>
</template>

<script setup>
// left
import LeftTop from "./parts/left-top.vue";
import LeftCenter from "./parts/left-center.vue";
import LeftBottom from "./parts/left-bottom.vue";

// center
import CenterTop from "./parts/center-top.vue";
import CenterCenter from "./parts/center-center.vue";
import CenterBottom from "./parts/center-bottom.vue";

// right
import RightTop from "./parts/right-top.vue";
import RightCenter from "./parts/right-center.vue";
import Top from './parts/top.vue'
import { computed, onMounted, ref, watch,onUnmounted } from "vue";
import  api from "../../api/car-board"

let carIndexData =ref()
let carEchatsData =ref()
let timer;
const leftTime =ref("1")
const handleChildEvent =(v)=>{
  clearInterval(timer);
  leftTime.value=String(v+1)
  getAllData()
  timer = setInterval(getAllData, 5000);
}

const getAllData =()=>{
  // 今日车辆数据+今日车辆类型+车位统计+车辆出入记录+车辆告警+滞留车辆
  api.getCarsIndex().then(res=>{
    carIndexData.value=res.data
  })
  // 根据时间获取过车辆态势趋势图
  api.getCarsEchats({type:leftTime.value}).then(res=>{
    carEchatsData.value=res.data
  })
}

// 获取项目
onMounted(async () => {
  getAllData();
  timer = setInterval(getAllData, 10000);

});

onUnmounted(() => {
    clearInterval(timer);
});

</script>

<style lang="scss" scoped>
.carCard{
  width: 200px;
  border: 1px solid red;
}
.page-prj {
  height: 60%;

  justify-content: space-between;
  &__left,
  &__right {
    width: 540px;
  }
  &__center {
    margin: 0px 20px;
    position: relative;
    flex: 1;
    width: 0px;
    display: flex;
    flex-direction: column;
  }
  .legend-box {
    position: absolute;
    right: 12px;
    bottom: 12px;
    padding: 13px 15px;
    border: 1px solid #24c1f7;
    z-index: 100;
    background-color: rgba(18, 33, 76, 0.8);
    display: flex;
    flex-direction: column;
    .el-checkbox {
      &:nth-child(n + 2) {
        margin-top: 16px;
      }
      --el-checkbox-disabled-checked-input-fill: #409eff;
      --el-checkbox-disabled-checked-input-border-color: #409eff;
      --el-checkbox-disabled-checked-icon-color: #ffffff;
      ::v-deep(.el-checkbox__label) {
        display: inline-flex;
        align-items: center;
      }
      img {
        width: 28px;
      }
      span {
        margin-left: 10px;
        font-weight: 600;
        font-weight: 500;
        font-size: 16px;
        color: #cfe9ff;
      }
    }
  }
}
.content-box1 {
  ::v-deep {
    .content-box {
      width: 70% !important;
    }
  }
}
</style>

<style lang="scss">
.prj-name {
  flex: 2 !important;
}
.dept-name {
  min-width: 300px !important;
}
</style>
